<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">全局渠道表 - 登记渠道</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:columnToggler datasource="bananaCommonActivityRegisterDataTable" trigger="toggler"/>

                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         actionListener="#{bananaCommonActivityRegisterBean.onReset()}"
                                         process="@this"
                                         update="@form"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         ajax="false">
                            <p:dataExporter type="xls" target="bananaCommonActivityRegisterDataTable"
                                            fileName="export"
                                            postProcessor="#{bananaCommonActivityRegisterBean.postProcessXLS}"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card ui-g-12">
                            <div class="ui-g-12">
                                <h3><b>查询条件
                                    <h:outputText id="content" value="统计口径" style="float: right;">
                                    </h:outputText>
                                    <p:tooltip id="toolTipContent" for="content" position="bottom">
                                        <p:graphicImage
                                                url="https://img.shuixindk.cn/loan-management/statistics1553319613682.jpg"
                                                width="1200"/>
                                    </p:tooltip>
                                </b></h3>
                            </div>
                            <div class="ui-g-1">
                                <p:outputLabel value="日期"/>
                            </div>
                            <div class="ui-g-5">
                                <p:calendar value="#{bananaCommonActivityRegisterBean.$.startDate}"
                                            styleClass="autoWidthCalendar"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"
                                            autocomplete="off"/>
                                <span>  —  </span>
                                <p:calendar value="#{bananaCommonActivityRegisterBean.$.endDate}"
                                            styleClass="autoWidthCalendar"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"
                                            autocomplete="off"/>
                            </div>
                            <div class="ui-g-1">
                                <p:outputLabel value="渠道UV"/>
                            </div>
                            <div class="ui-g-5">
                                <p:inputText style="width: 47%;" value="#{bananaCommonActivityRegisterBean.$.uvStart}"/>
                                <span>—</span>
                                <p:inputText style="width: 47%;" value="#{bananaCommonActivityRegisterBean.$.uvEnd}"/>
                            </div>
                            <div class="ui-g-1">
                                <p:outputLabel value="渠道类型"/>
                            </div>
                            <div class="ui-g-5">
                                <p:selectCheckboxMenu value="#{bananaCommonActivityRegisterBean.$.channelGroups}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItems
                                            value="#{bananaCommonActivityRegisterBean.dictionaries[DictionaryCode.CHANNEL_GROUP]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectCheckboxMenu>
                            </div>
                            <div class="ui-g-1">
                                <p:outputLabel for="channelId" value="渠道"/>
                            </div>
                            <div class="ui-g-5">
                                <p:selectCheckboxMenu id="channelId"
                                                      value="#{bananaCommonActivityRegisterBean.$.channelCode}"
                                                      updateLabel="true" multiple="true" filter="true"
                                                      filterMatchMode="contains">
                                    <f:selectItems value="#{bananaCommonActivityRegisterBean.bananaProductChannels}"
                                                   var="channel"
                                                   itemValue="#{channel.channelCode}"
                                                   itemLabel="#{channel.channelName}(#{channel.channelCode})"/>
                                </p:selectCheckboxMenu>
                            </div>
                            <div class="ui-g-1">
                                <p:outputLabel for="platform" value="平台"/>
                            </div>
                            <div class="ui-g-5">
                                <p:selectOneButton id="platform" value="#{bananaCommonActivityRegisterBean.$.platform}">
                                    <f:selectItem itemLabel="安卓" itemValue="android" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="苹果" itemValue="ios" noSelectionOption="true"/>
                                </p:selectOneButton>
                            </div>
                            <div class="ui-g-1">
                                <p:outputLabel for="activityId" value="活动ID"/>
                            </div>
                            <div class="ui-g-5">
                                <p:inputText id="activityId" value="#{bananaCommonActivityRegisterBean.$.activityId}">
                                </p:inputText>
                            </div>
                            <div class="ui-g-12">
                            </div>
                            <div class="ui-g-1">
                                <p:outputLabel value="产品"/>
                            </div>
                            <div class="ui-g-11">
                                <p:selectManyButton value="#{bananaCommonActivityRegisterBean.$.productIds}">
                                    <f:selectItems
                                            value="#{bananaCommonActivityRegisterBean.bananaProducts}"
                                            var="product"
                                            itemLabel="#{product.name}" itemValue="#{product.productId}"/>
                                </p:selectManyButton>
                            </div>
                            <div class="card ui-g-12">
                                <p:dataTable id="bananaCommonActivityRegisterDataTable"
                                             style="width: 150%;text-align: match-parent"
                                             var="bananaCommonActivityRegister"
                                             value="#{bananaCommonActivityRegisterBean.lazyDataModel}"
                                             rows="#{constants:get('ROWS')}"
                                             lazy="true"
                                             paginator="true"
                                             paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                             rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                             emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                             scrollable="true"
                                             scrollWidth="97%"
                                             reflow="true"
                                             resizableColumns="true">

                                    <p:column headerText="时间" style="width: 75px;">
                                        <h:outputText value="#{bananaCommonActivityRegister.date}">
                                            <f:convertDateTime pattern="#{constants:get('DATE_FORMAT')}"/>
                                        </h:outputText>
                                    </p:column>

                                    <p:column headerText="平台">
                                        <h:outputText value="#{bananaCommonActivityRegister.platform}"/>
                                    </p:column>

                                    <p:column headerText="产品">
                                        <h:outputText
                                                value="#{bananaCommonActivityRegisterBean.translateProduct(bananaCommonActivityRegister.productId)}"/>
                                    </p:column>

                                    <p:column headerText="渠道类型">
                                        <h:outputText
                                                value="#{bananaCommonActivityRegisterBean.translateChannelGroup(bananaCommonActivityRegister.channel)}"/>
                                    </p:column>

                                    <p:column headerText="渠道" style="width: 120px;">
                                        <h:outputText
                                                value="#{bananaCommonActivityRegisterBean.translateProductChannel(bananaCommonActivityRegister.channel)}"/>
                                    </p:column>

                                    <p:column headerText="活动ID">
                                        <h:outputText value="#{bananaCommonActivityRegister.activityId}"/>
                                    </p:column>

                                    <p:column headerText="外推模板ID">
                                        <h:outputText value="#{bananaCommonActivityRegister.templateId}"/>
                                    </p:column>

                                    <p:column headerText="H5-访问">
                                        <h:outputText value="#{bananaCommonActivityRegister.h5Uv}"/>
                                    </p:column>

                                    <p:column headerText="H5-登记">
                                        <h:outputText value="#{bananaCommonActivityRegister.h5Record}"/>
                                    </p:column>

                                    <p:column headerText="H5-注册">
                                        <h:outputText value="#{bananaCommonActivityRegister.h5Register}"/>
                                    </p:column>

                                    <p:column headerText="App-登录">
                                        <h:outputText value="#{bananaCommonActivityRegister.appLogin}"/>
                                    </p:column>

                                    <p:column headerText="App-注册">
                                        <h:outputText value="#{bananaCommonActivityRegister.appRegister}"/>
                                    </p:column>

                                    <p:column headerText="H5-注册 -> APP注册">
                                        <h:outputText
                                                value="#{bananaCommonActivityRegister.h5Register == 0 ? 0 : bananaCommonActivityRegister.appRegister / bananaCommonActivityRegister.h5Register}">
                                            <f:convertNumber pattern="##%"/>
                                        </h:outputText>
                                    </p:column>

                                    <p:column headerText="App绑卡">
                                        <h:outputText value="#{bananaCommonActivityRegister.appBinding}"/>
                                    </p:column>

                                    <p:column headerText="App登录 -> App绑卡">
                                        <h:outputText
                                                value="#{bananaCommonActivityRegister.appLogin == 0 ? 0 : bananaCommonActivityRegister.appBinding / bananaCommonActivityRegister.appLogin}">
                                            <f:convertNumber pattern="##%"/>
                                        </h:outputText>
                                    </p:column>

                                    <p:column headerText="API进件人数">
                                        <h:outputText value="#{bananaCommonActivityRegister.appApply}"/>
                                    </p:column>

                                    <p:column headerText="API放款">
                                        <h:outputText value="#{bananaCommonActivityRegister.appLoanSuccess}"/>
                                    </p:column>

                                    <p:column headerText="API放款总额">
                                        <h:outputText value="#{bananaCommonActivityRegister.appLoanTotalAmount}"/>
                                    </p:column>

                                    <p:column headerText="取现">
                                        <h:outputText value="#{bananaCommonActivityRegister.appCash}"/>
                                    </p:column>

                                    <p:column headerText="信用卡平均额度(元)">
                                        <h:outputText value="#{bananaCommonActivityRegister.averageQuota}"/>
                                    </p:column>

                                    <p:column headerText="人均参与">
                                        <h:outputText value="#{bananaCommonActivityRegister.averageJoin}"/>
                                    </p:column>
                                </p:dataTable>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
